package com.bt.dao;

import com.bt.entity.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface UserMapper extends Mapper<User> {
    @Select("select *from m_user where name=#{name} and password=#{password}")
    User login(@Param("name")String name,@Param("password") String passwrod);

    @Select("select * from m_user")
    List<User> getUserList();
    @Select({
            "<script>",
            "SELECT * FROM m_user",
            "<where>",
            "   <if test='name != null and name != \"\"'>",
            "       AND name LIKE CONCAT('%', #{name}, '%')",
            "   </if>",
            "   <if test='sex != null and sex != \"\"'>",
            "       AND sex = #{sex}",
            "   </if>",
            "   <if test='address != null and address != \"\"'>",
            "       AND address LIKE CONCAT('%', #{address}, '%')",
            "   </if>",
            "</where>",
            "</script>"
    })
    List<User> selectByCondition(User user);
}
